#include "stdafx.h"
#include "MeshManager.h"

#include "SimpleMeshCreator.h"
#include "Mesh.h"

using namespace mgfx;

void MeshManager::addMesh(const string & key, Mesh * mesh)
{
	mMeshes[key] = mesh;
}

Mesh * MeshManager::getMesh(const string & key)
{
	assert(mMeshes.find(key) != mMeshes.end());
	return mMeshes[key];
}

void MeshManager::init()
{
	Mesh * mesh = SimpleMeshCreator::createSphere(3, 20, 20);
	addMesh("Sphere", mesh);
	mDefaultMesh = mesh;

	addMesh("Quad", SimpleMeshCreator::createQuad(5, 5, 30, 15, 15));
	addMesh("Box", SimpleMeshCreator::createBox(5, 3, 3));
}

void MeshManager::deinit()
{
	for(MeshMap::iterator it = mMeshes.begin() ; it != mMeshes.end() ; ++it)
		delete it->second;
}